<?php
namespace app\user\validate\teacher;

use think\Validate;

/**
 * 讲师素材验证
 */
class Material extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'type'          => 'require|integer|in:1,2,3,4',
        'category'      => 'integer',
        'cate_id'       => 'require|integer',
        'attach_ids'    => 'require|/^[\d,]+$/',
        'id'            => 'require|number',
        'title'         => 'require',
        'ids'           => 'require|/^[\d,]+$/',
        'trashed'       => 'require|in:0,1'
    ];

    protected $field = [
        'type'          => '素材类型',
        'category'      => '素材分组',
        'cate_id'       => '素材分组',
        'attach_ids'    => '素材附件',
        'id'            => '素材',
        'title'         => '素材名称',
        'ids'           => '素材',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [

    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'list'      => ['type', 'category', 'trashed'],
        'add'       => ['type', 'cate_id', 'attach_ids'],
        'name'      => ['id', 'title'],
        'cate'      => ['ids', 'cate_id'],
        'delete'    => ['ids', 'trashed'],
        'deleted'   => ['type'],
    ];


}
